<template>
  <view class="list-item-top">
    <view class="list-item-top-left">
      <image :src="orderitem.mch.logo" mode="aspectFit" v-if="orderitem.mch"></image>
      <!-- <i class="iconfont " style="font-size:46rpx;"></i> -->
      <view v-if="orderitem.mch">{{ orderitem.mch.name }}</view>
      <!-- <image :src="asyncImgs.my.icon_right_3" mode="aspectFit"></image> -->
      <i class="iconfont icon-arrow-right" v-if="orderitem.mch"></i>
    </view>
    <view class="list-item-top-right" :style="{ color: orderStatus.color }">
      <template>
        {{ orderStatus.str }}
      </template>
    </view>
  </view>
</template>

<script>
export default {
  data() {
    return {};
  },
  props: {
    orderitem: {
      type: Object,
      default: () => {
        return {};
      },
    },
    status: {
      type: Number,
      default: 0,
    },
  },
  computed: {
    orderStatus() {
      let str = "",
        color = "#F7271F";
      // 0所有可售后订单  1处理中订单 2已完成订单
      if(this.orderitem.is_user_cancel == 1) {
        str = this.$t('shop.cancled')
        color = "#8C8C8C";
      }else {
        if (this.status == 0) {
          if (
            this.orderitem.is_agree == 0 &&
            this.orderitem.refund_status == 0 &&
            this.orderitem.is_user_send == 0
          ) {
            str = "";
          }
        }
        if (this.status == 1) {
          if (
            this.orderitem.is_agree == 0 &&
            this.orderitem.refund_status == 0 &&
            this.orderitem.is_user_send == 0
          ) {
            str = this.$t('order.waitDo');
          }
          if (
            this.orderitem.refund_status == 0 &&
            this.orderitem.is_agree == 1 &&
            this.orderitem.is_user_send == 0
          ) {
            str = this.$t('order.agreed');
          }
          if (
            this.orderitem.refund_status == 0 &&
            this.orderitem.is_agree == 1 &&
            this.orderitem.is_user_send == 1
          ) {
            str = this.$t('order.waitBu');
          }
        }
        if (this.status == 2) {
          if (this.orderitem.refund_status == 1) {
            str = this.$t('order.refunded');
            color = "#8C8C8C";
          }
          if (this.orderitem.refund_status == 3) {
            str = this.$t('shareholder.refuced');
          }
        }
      }
      return { str, color };
    },
  },
  methods: {
    deleteItem() {
      uni.showModal({
        title: this.$t('order.prompt'),
        content: this.$t('order.confirmDel'),
        success: function (res) {
          if (res.confirm) {
          } else if (res.cancel) {
          }
        },
      });
    },
  },
};
</script>

<style lang="scss" scoped>
.list-item-top {
  display: flex;
  justify-content: space-between;
  align-items: center;

  .list-item-top-left {
    display: flex;
    align-items: center;

    .iconfont{
      font-size: 22rpx;
    }

    view {
      // margin: 0rpx 10rpx;
      font-size: 28rpx;
      color: #262626;
      font-weight: 500;
      line-height: 44rpx;
    }

    image:first-child {
      width: 28rpx;
      height: 28rpx;
    }

    image:last-child {
      width: 12rpx;
      height: 20rpx;
    }
  }

  .list-item-top-right {
    font-size: 26rpx;
    color: #f23030;

    image {
      width: 28rpx;
      height: 28rpx;
      margin-left: 30rpx;
    }
  }
}
</style>
